#ifndef CAMERATHREAD_H
#define CAMERATHREAD_H

#include <QThread>
#include "recognitionview.h"
#include "imagecomparator.h"

using namespace views;

namespace controllers {

    #define NORMAL_COMPARISON_THRESHOLD 15000
    #define HUE_COMPARISON_THRESHOLD    25000
    #define SPARSE_COMPARISON_THRESHOLD 1000

    class CameraThread : public QThread
    {
        Q_OBJECT

    public:
        explicit    CameraThread(QObject *parent = 0);
        virtual     ~CameraThread();
        void        setView(RecognitionView* rv);
        void        saveReferenceImage();
        void        recordVideo();
        void        takeSnapshotImage();
        void        startObjectRecognition();
        void        computeDBImageHistograms(QVector<Mat> images);

    protected:
        virtual void run();

    signals:

    public slots:

    private:
        int                 _frames;
        bool                _referenceTaken;
        bool                _recordingVideo;
        bool                _objectDetected;
        bool                _processingObject;
        double              _threshold;
        Mat                 _currentFrame;
        RecognitionView     *_recognitionView;
        ImageComparator     *_imageComparator;
        QVector<MatND>      *_dbImageHistograms;
        QVector<MatND>      *_dbImageHueHistograms;
        QVector<SparseMat>  *_dbImageSParseHistograms;
        QVector<Mat>        _dbImages;
    };
}

#endif // CAMERATHREAD_H
